//
//  ForumDetailCell.m
//  cityCar
//
//  Created by yao on 14-10-31.
//  Copyright (c) 2014年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "ForumDetailCell.h"
#import "WebColor.h"

@implementation ForumDetailCell

- (void)dealloc
{
    [_forum release];
    [_titleLabel release];
    [_nameLabel release];
    [_viewAndReplyLabel release];
    [super dealloc];
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
        self.viewAndReplyLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.viewAndReplyLabel];
        [_viewAndReplyLabel release];
        
        self.forum = [[Forum alloc] init];
        
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    [self setupView];
    
}

- (void)setupView
{
    CGFloat x = self.contentView.bounds.size.width;
    CGFloat y = self.contentView.bounds.size.height;
    
    self.titleLabel.frame = CGRectMake(20, 5, x - 40, y / 3 * 2);
    self.nameLabel.frame = CGRectMake(20, y / 3 * 2 + 5, (x - 20) / 2, y / 3 - 5);
    self.viewAndReplyLabel.frame = CGRectMake((x - 20) / 2,  y / 3 * 2 + 5, (x - 20) / 2, y / 3 - 5);
    
    
    self.titleLabel.numberOfLines = 0;
    
    self.nameLabel.font = [UIFont systemFontOfSize:13];
    self.nameLabel.textColor = [WebColor silver];
    
    self.viewAndReplyLabel.font = [UIFont systemFontOfSize:13];
    self.viewAndReplyLabel.textAlignment = NSTextAlignmentRight;
    self.viewAndReplyLabel.textColor = [WebColor silver];
    
}

- (void)setForum:(Forum *)forum
{
    if (forum != _forum) {
        [_forum release];
        _forum = [forum retain];
    }
    self.titleLabel.text = _forum.title;
    self.nameLabel.text = _forum.forumName;
    self.viewAndReplyLabel.text = [NSString stringWithFormat:@"%@阅/%@回",
                                   _forum.view, _forum.replyCount];
    
    
}


- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
